import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Window 2.0

Image {
	id: img
	property bool closeDoDestroy : true
	property alias titleImg: titleImg

	source: "image://default/big_dialog_bg.png"
	x: (parent.width - width) / 2
	y: (Screen.height - img.height) * 0.382

	Image {
		id: titleImg
	    x: (parent.width - width) / 2
	    y: -20
	}

	function setTitle(t)
	{
		title.source = t;
	}

	ImgBtn {
		normalImg: "image://default/close.png"
		anchors.right: parent.right
		showAni: true
		onClicked: {
			img.visible = true;
			hideAni.start();
		}
	}

	onVisibleChanged: {
		if (visible) {
	    	showAni.start();
		}
	}

	PropertyAnimation on scale {
		id: showAni
		running: false
		duration: 200
		from: 0
		to: 1
	}

	PropertyAnimation on scale {
		id: hideAni
		running: false
		duration: 200
		from: 1
		to: 0
		onStopped: {
			if (closeDoDestroy)
				img.destroy();
			else
				img.visible = false;
		}
	}
}
